<%@ page contentType="text/html;charset=UTF-8" %>

<html>
<head>
	<title>栏目新增/修改</title>
	
	<%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/import.jsp" %>
    <script type="text/javascript" src="${ctx}/js/easyui/extendvalidate.js"></script>
	<script src="${ctx}/js/uct/uct_dict.js"></script>
	<script type="text/javascript" src="${ctx}/js/uct//uct_form.js"></script>
    <script type="text/javascript" src="${ctx}/js/uct/date.js"></script>
	<script type="text/javascript" src="${ctx}/js/zbxtools.js"></script>
	<script>

	$(function(){
		$('#channelSaveForm').form({
		    onSubmit:function(){
		    	return  $(this).form('validate');
		    },
		    success:function(data){
		    	var result = jQuery.parseJSON(data);
		    	if(result.flag=='T'){
		    		$.messager.alert('提交结果', '操作成功', 'info',function(){
		    		    parent.closeOrgWindow();
		    		    if("0"=="${item.parentId}"){
		    		    	parent.reload();
		    		    }else{
		    		  		parent.reloadTree('${item.parentId}','${item.channelId}');
		    		    }
		    		});
		    	}else{
		    		$.messager.alert('提交结果', result.msg, 'info');
		    	}        
		    }
		});
		
		if("${item.channelId}"!=null&&"${item.channelId}"!=""){
			$("#item.codeName").attr("readonly",true);
		}
		
	}) ;
	$.extend($.fn.validatebox.defaults.rules, {
    minLength: {
        validator: function(value, param){
            return value.length >= param[0];
        },
        message: 'Please enter at least {0} characters.'
    }
});

</script>

<body>	

<div id="tip"></div>
	<form id="channelSaveForm" name="channelSaveForm" method="post" action="save.action">
	    <input type="hidden" name="formToken" id="formToken" value="${formToken}">
		<input type="hidden" name="channelId" id="channelId" value="${item.channelId}"/>
		<input type="hidden" name="parentId" id="parentId" value="${item.parentId}"/>
		<table class="tab_info" >
			<tr >
				<th>栏目名称<span style="color:red;" >*</span></th>
				<td>
				<input name="channelName"  id="channelName" value="${item.channelName}"
				class="easyui-validatebox" required="true" size="30" validType="length[2,120]" 
				missingMessage="请输入栏目名称" invalidMessage="应为2~120个字" />				
				</td>
			</tr>
			<tr>
				<th>栏目标识<span style="color:red;" >*</span></th>
				<td>
				
				<input id="codeName" name="codeName"  value="${item.codeName}" 
				class="easyui-validatebox" required="true" size="30" validType="english" 
				missingMessage="请输入栏目标识"  />
				
				</td>
			</tr>
			<tr>
				<th>显示名称<span style="color:red;" >*</span></th>
				<td><input id="displayName" name="displayName"  value="${item.displayName}"
				class="easyui-validatebox" required="true" size="30" validType="length[0,120]" 
				missingMessage="请输入显示名称" invalidMessage="不能超过120个字" />				
				</td>
			</tr>
					
			<tr>
				<th>栏目类型</th>
				<td>
				<select id="channelType" name="channelType" style="width:183px;" onchange="showText()">
				<option value="more" selected="selected">普通栏目</option>
				<option value="only">单稿件栏目</option>
				<option value="link">链接栏目</option>
				</select>
				</td>
			</tr>
			<tr>
				<th>内容模板</th>
				<td>
				<input id="tempName" name="tempName"  value="${item.tempName}"
				class="easyui-validatebox" required="true" size="30" validType="length[0,120]" 
				missingMessage="请输入内容模板名称" invalidMessage="不能超过120个字" /><span style="color:red;" >如：article.inc</span>
				</td>
			</tr>			
			<tr id="artice_url">
			    <th>链接地址<span style="color:red;" >*</span></th>
				<td colspan="3"><input name="redirectUrl" id="redirectUrl" value="${item.redirectUrl}" size="30"/>  <span style="color:red;" >如：http://www.baidu.com/</span>
				</td>
			</tr>
			<tr>
				<th>是否导航</td>
				<td>
				<input type="radio" name="isNavigation" id="isNavigation_1" value="1" checked="checked"/>是
				<input type="radio" name="isNavigation"  id="isNavigation_0" value="0" />否
				</td>
			</tr>
			<tr>
				<th>状态</td>
				<td>
				<input type="radio" name="status" id="status_1" value="1" checked="checked"/>启用
				<input type="radio" name="status"  id="status_0" value="0" />停用
				</td>
			</tr>							
				<tr>
				<td colspan="2" style="text-align: center;">	
				<input class="bluebtn" type="submit" value="提交"/>	
				<input class="bluebtn" type="button" value=" 关 闭 " onclick="parent.closeChannelAddWindow()">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

<script>
	$(function(){
		$("#artice_url").hide();
		if(""=="${item.tempName}"){
		   $("#tempName").val("article.inc");
		}
		ZBXTools.initRadio("status","${item.status}");
		ZBXTools.initRadio("isNavigation","${item.isNavigation}");
		ZBXTools.initSelect("channelType","${item.channelType}");
	});
	function showText(){
	    var objS = document.getElementById("channelType");
	    var grade = objS.options[objS.selectedIndex].value;
		    if(grade=="link"){
		    	$("#artice_url").show();
		    	$('#url').attr('required', true);
		    }else{
		    	$("#artice_url").hide();
		    	$('#url').attr('required', false);
		    }
	   }
</script>